package com.cy.pj.sys.web.advice;

import com.cy.pj.sys.web.pojo.JsonResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @DATE: 2021/3/16 15:34
 * @Author: LuckyH
 */
@RestControllerAdvice
@Slf4j
public class GlobalExceptionHandler{

    @ExceptionHandler(RuntimeException.class)
    public JsonResult doHandlerException(RuntimeException e){
        return new JsonResult(0,e.getMessage());
    }

    @ExceptionHandler(NumberFormatException.class)
    public JsonResult doHandlerNumberFormatException(NumberFormatException e){
//        e.printStackTrace();
//        log.error("exception {}","你传入的参数类型不匹配");
        return new JsonResult(0,"你传入的参数类型不匹配");
    }
}
